package design.observer;

import lombok.Data;

import java.util.*;

/**
 * @author ZH
 */
@Data
public class GraphicCard extends Observable {
    private Integer price = 0;
    public void priceChange(Integer price) throws Exception {
        Integer old = this.getPrice();
        if (old > price){
            System.out.println("显卡降价啦");
        }else {
            System.out.println("显卡又涨价了");
        }
        this.setPrice(price);
        setChanged();
        notifyObservers(old > price);
    }
}
